<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\Db;
// 应用公共文件
/**
 * 验证手机短信
 * @param $msg_id
 * @param $code
 * @return \think\Response
 */
function checkPhoneCode($msg_id, $code)
{
    $app_key       = \think\Config::get('JiGuang_app_key');
    $master_secret = \think\Config::get('JiGuang_master_secret');
    $client        = new \JiGuang\JSMS($app_key, $master_secret, ['ssl_verify' => false]);
    $response      = $client->checkCode($msg_id, $code);
    if (json_decode($response['http_code']) != 200) {
        return false;
    }
    return true;
}

/**
 * 随机生成付款钱包
 */
function randWallet()
{
    $count  = Db::name('wallet')->count();
    $wallet = Db::name('wallet')->find(rand(1, $count));
    return $wallet['wallet'];
}